unit UPharmacyStock;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, AdvPanel, cxGraphics,
  cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
  dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel,
  dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
  dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
  dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
  dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver,
  dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010,
  dxSkinWhiteprint, dxSkinXmas2008Blue, cxGroupBox, DBAdvGlowNavigator,
  cxStyles, dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, cxDataStorage,
  cxNavigator, Data.DB, cxDBData, cxGridLevel, cxClasses, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, UDMPharmacy,
  AdvToolBar, AdvToolBarStylers, cxTextEdit, cxMaskEdit, cxDropDownEdit,
  cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, Vcl.StdCtrls, cxDBEdit,
  cxRadioGroup, cxCheckBox, UDMItems, Vcl.DBCtrls, UDMSettings, UPharmacyStockTransfer,
  UPharmacyStockTransferRequest, UPharmacyEncounter, UPharmacyStockSubNew, USupplierInvoice,
  UPharmacyReturn, UPharmacyItemNaming, UPharmacyStockCount;

type
  TFPharmacyStock = class(TForm)
    AdvPanel1: TAdvPanel;
    AdvPanelStyler1: TAdvPanelStyler;
    cxGroupBox1: TcxGroupBox;
    AdvPanel2: TAdvPanel;
    DBAdvGlowNavigator1: TDBAdvGlowNavigator;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    AdvToolBarPager1: TAdvToolBarPager;
    AdvToolBarPager11: TAdvPage;
    AdvToolBarOfficeStyler1: TAdvToolBarOfficeStyler;
    Label6: TLabel;
    cxDBTextEdit1: TcxDBTextEdit;
    Label7: TLabel;
    cxDBTextEdit2: TcxDBTextEdit;
    cxGroupBox2: TcxGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    cxDBLookupComboBox1: TcxDBLookupComboBox;
    cxDBLookupComboBox2: TcxDBLookupComboBox;
    cxDBLookupComboBox3: TcxDBLookupComboBox;
    cxDBLookupComboBox4: TcxDBLookupComboBox;
    cxDBLookupComboBox5: TcxDBLookupComboBox;
    cxGroupBox3: TcxGroupBox;
    cxDBRadioGroup1: TcxDBRadioGroup;
    Label8: TLabel;
    cxDBTextEdit3: TcxDBTextEdit;
    Label9: TLabel;
    cxDBTextEdit4: TcxDBTextEdit;
    cxGroupBox4: TcxGroupBox;
    cxDBRadioGroup2: TcxDBRadioGroup;
    Label10: TLabel;
    cxDBTextEdit5: TcxDBTextEdit;
    Label11: TLabel;
    cxDBTextEdit6: TcxDBTextEdit;
    cxGrid1DBTableView1dept_id: TcxGridDBColumn;
    cxGrid1DBTableView1qty: TcxGridDBColumn;
    cxGrid1DBTableView1cost_price: TcxGridDBColumn;
    cxGrid1DBTableView1sell_price: TcxGridDBColumn;
    cxGrid1DBTableView1discount: TcxGridDBColumn;
    cxGrid1DBTableView1expiry_date: TcxGridDBColumn;
    cxGrid1DBTableView1cnss_etage: TcxGridDBColumn;
    cxGrid1DBTableView1cnss_bloc: TcxGridDBColumn;
    cxGrid1DBTableView1cnss_urgent: TcxGridDBColumn;
    cxGrid1DBTableView1coop_etage: TcxGridDBColumn;
    cxGrid1DBTableView1coop_bloc: TcxGridDBColumn;
    cxGrid1DBTableView1coop_urgent: TcxGridDBColumn;
    cxGrid1DBTableView1private_etage: TcxGridDBColumn;
    cxGrid1DBTableView1private_bloc: TcxGridDBColumn;
    cxGrid1DBTableView1private_urgent: TcxGridDBColumn;
    cxGrid1DBTableView1armee_etage: TcxGridDBColumn;
    cxGrid1DBTableView1armee_urgent: TcxGridDBColumn;
    cxGrid1DBTableView1armee_bloc: TcxGridDBColumn;
    cxGrid1DBTableView1self_pay_etage: TcxGridDBColumn;
    cxGrid1DBTableView1self_pay_urgent: TcxGridDBColumn;
    cxGrid1DBTableView1self_pay_bloc: TcxGridDBColumn;
    cxGrid1DBTableView1Column1: TcxGridDBColumn;
    DBCheckBox1: TDBCheckBox;
    DBCheckBox2: TDBCheckBox;
    DBCheckBox3: TDBCheckBox;
    Label12: TLabel;
    cxDBTextEdit7: TcxDBTextEdit;
    AdvToolBar3: TAdvToolBar;
    AdvToolBar4: TAdvToolBar;
    Label13: TLabel;
    cxDBLookupComboBox6: TcxDBLookupComboBox;
    procedure DBAdvGlowNavigator1BtnCancel(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnEdit(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnFirst(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnInsert(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnLast(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnNext(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnPost(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnPrior(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnRefresh(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure AdvToolBar1Click(Sender: TObject);
    procedure AdvToolBar3Click(Sender: TObject);
    procedure AdvToolBar4Click(Sender: TObject);
    procedure AdvToolBar2Click(Sender: TObject);
    procedure cxDBRadioGroup1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FPharmacyStock: TFPharmacyStock;

implementation

{$R *.dfm}

procedure TFPharmacyStock.AdvToolBar1Click(Sender: TObject);
begin
  FSupplierInvoice.show;
end;

procedure TFPharmacyStock.AdvToolBar2Click(Sender: TObject);
begin
  FPharmacyStockCount.Show;
end;

procedure TFPharmacyStock.AdvToolBar3Click(Sender: TObject);
begin
  FPharmacyReturn.Show;
end;

procedure TFPharmacyStock.AdvToolBar4Click(Sender: TObject);
begin
  FPharmacyItemNaming.Show;
end;

procedure TFPharmacyStock.cxDBRadioGroup1Click(Sender: TObject);
var
  name1 : string;
  name2 : string;
begin
  if  self.cxDBRadioGroup1.EditValue = '2' then
  begin
    name1 := Self.cxDBTextEdit2.EditValue;
    name2 := Self.cxDBTextEdit1.EditValue;

    DMPharmacy.his_pharmacy_stock.FieldByName('name1').Value := name1;
    DMPharmacy.his_pharmacy_stock.FieldByName('name2').Value := name2;
    DMPharmacy.his_pharmacy_stock.FieldByName('usable_name').Value := '1';
  end;
end;

procedure TFPharmacyStock.DBAdvGlowNavigator1BtnCancel(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;

  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;

  DMPharmacy.his_pharmacy_stock.Cancel;
end;

procedure TFPharmacyStock.DBAdvGlowNavigator1BtnEdit(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := true;

  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;

  DMPharmacy.his_pharmacy_stock.Edit;
end;

procedure TFPharmacyStock.DBAdvGlowNavigator1BtnFirst(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;

  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;

  DMPharmacy.his_pharmacy_stock.First;
end;

procedure TFPharmacyStock.DBAdvGlowNavigator1BtnInsert(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := true;

  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;

  DMPharmacy.his_pharmacy_stock.Insert;
end;

procedure TFPharmacyStock.DBAdvGlowNavigator1BtnLast(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;

  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;

  DMPharmacy.his_pharmacy_stock.Last;
end;

procedure TFPharmacyStock.DBAdvGlowNavigator1BtnNext(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;

  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;

  DMPharmacy.his_pharmacy_stock.Next;
end;

procedure TFPharmacyStock.DBAdvGlowNavigator1BtnPost(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := true;
  DMPharmacy.his_pharmacy_stock.Post;
  DMPharmacy.his_pharmacy_stock.RefreshRecord;

  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;

  Self.AdvPanel1.Enabled := false;
end;

procedure TFPharmacyStock.DBAdvGlowNavigator1BtnPrior(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;

  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;

  DMPharmacy.his_pharmacy_stock.Prior;
end;

procedure TFPharmacyStock.DBAdvGlowNavigator1BtnRefresh(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;

  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;

  DMPharmacy.his_pharmacy_stock.RefreshRecord;
end;

procedure TFPharmacyStock.FormActivate(Sender: TObject);
begin
  DMPharmacy.his_pharmacy_stock_sub_q.Active := False;
  DMPharmacy.his_pharmacy_stock_sub_q.ParamByName('a').Value := DMPharmacy.his_pharmacy_stock.FieldByName('parmacy_stock_id').Value;
  DMPharmacy.his_pharmacy_stock_sub_q.Active := True;
end;

end.
